using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;

namespace Magiq.Sql {
  public static class SqlTypesExtension {
    private static readonly Dictionary<Type, string> SqlTypes = new Dictionary<Type, string>
                                                                  {
                                                                    {typeof (Int16), "int"},
                                                                    {typeof (Int32), "int"},
                                                                    {typeof (Int64), "bigint"},
                                                                    {typeof (string), "varchar(255)"},
                                                                    {typeof (Guid), "uniqueidentifier"}
                                                                  };

    public static string SqlType(this MetaDataMember self) {
      return self.DbType ?? SqlTypes[self.Type];
    }
  }
}